package com.service;

import com.mapper.RecordMapper;
import com.pojo.StorageRecord;
import com.pojo.Supplier;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service("/recordService")
public class RecordServiceImpl implements RecordService{
    @Resource
    private RecordMapper recordMapper;
    @Override
    public List<StorageRecord> select(String goodsName, Integer supplierId, Integer payStatus, Integer pageBegin, Integer pageSize) {
        List<StorageRecord> recordList = new ArrayList<>();
        try{
            recordList = recordMapper.select(goodsName,supplierId,payStatus,((pageBegin-1)*pageSize),pageSize);
        }catch (Exception e){
            e.printStackTrace();
        }
        return recordList;
    }

    @Override
    public int count(String goodsName, Integer supplierId, Integer payStatus) {
        int count = 0;
        try{
            count = recordMapper.count(goodsName, supplierId,payStatus);
        }catch (Exception e){
            e.printStackTrace();
        }
        return count;
    }

    @Override
    public boolean add(StorageRecord storageRecord) {
        boolean result=false;
        if(recordMapper.add(storageRecord)==1){
            result=true;
        }
        return result;
    }

    @Override
    public StorageRecord getStorageRecordById(String id) {
        return recordMapper.getStorageRecordById(id);
    }
}
